package com.selftool.gui.serverframe.action;

import com.selftool.base.NCButton;
import com.selftool.log.Logger;
import com.selftool.util.CommonUtil;

import javax.swing.*;
import java.io.File;
/**
* @Description: 初始化按钮
* @Author: CYQ
* @Date: 2024/2/20
*/
public class InitButton extends NCButton {
    /**
     * @param obj
     * @throws Exception
     */
    @Override
    protected void execute(Object obj) throws Exception {
        Logger.write("当前服务路径为："+System.getProperty("user.dir"));
        Logger.write("请选择home目录");
        JFileChooser jfile = new JFileChooser();
        jfile.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        jfile.showOpenDialog(null);
        File dialog=jfile.getSelectedFile();
        if(dialog == null){
            Logger.write("取消初始化");
        }else{
            String name = dialog.getPath();
            CommonUtil.setParameter("homepath",name,"home路径");
            Logger.write("已指定home路径为："+name+";后续使用此工具如无变动不需要重复指定");
        }
    }
}
